package com.xxx.modules.controller;;
import com.xxx.modules.service.SubjectService;
import com.xxx.modules.entity.Subject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * subject
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2023-04-29
 */
@RestController
@RequestMapping("/common/subject")
@Api(tags="subject")
public class SubjectController {
    @Autowired
    private SubjectService subjectService;

    /**
    *  获取所有专业信息
    * @param pageNum
    * @param pageSize
    * @param subject
    * @return
    */

    @GetMapping("/getSubjectInfo")
    @ApiOperation("获取所有专业信息")
    public Result getSubjectInfo(Subject subject, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Subject> data = subjectService.selectSubjectInfo(subject,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存专业信息
    * @param subject
    * @return
    */
    @PostMapping("/saveSubjectInfo")
    @ApiOperation("保存专业信息")
    public Result saveSubjectInfo(@RequestBody Subject subject){
        subjectService.saveSubjectInfo(subject);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新专业信息
     * @param subject
     * @return
     */

    @PutMapping("/updateSubjectInfo")
    @ApiOperation("更新专业信息")
    public Result updateSubjectInfo(@RequestBody Subject subject){
        subjectService.updateSubjectInfo(subject);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除专业信息
     * @param id
     * @return
     */
    @DeleteMapping("/delSubjectInfo")
    @ApiOperation("根据id删除专业信息")
    public Result delSubjectInfo(Integer id){
        subjectService.delSubjectInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除专业信息
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchSubjectInfo")
    @ApiOperation("根据id集合批量删除专业信息")
    public Result delBatchSubjectInfo(String idList){
        subjectService.delBatchSubjectInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}